package com.lechuang.goods.controller;

import com.lechuang.common.result.Result;
import com.lechuang.goods.dto.GoodsRegionSetSpuDTO;
import com.lechuang.goods.manager.GoodsRegionManager;
import com.lechuang.goods.vo.GoodsRegionListVO;
import com.lechuang.goods.vo.GoodsRegionCategoryVO;
import com.lechuang.goods.vo.GoodsRegionSpuVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/region")
@Tag(name = "商品区域")
public class GoodsRegionController {
    @Resource
    private GoodsRegionManager goodsRegionManager;

    @PostMapping("/list")
    @Operation(summary = "商品区域-列表")
    public Result<List<GoodsRegionListVO>> list(@Schema(description = "区域类型，1：默认区域，2：自定义区域") @RequestParam Integer regionType){
        List<GoodsRegionListVO> goodsRegionListVOList = goodsRegionManager.list(regionType);
        return Result.success(goodsRegionListVOList);
    }

    @PostMapping("/setSpu")
    @Operation(summary = "商品区域-设置商品")
    public Result<Object> setSpu(@RequestBody GoodsRegionSetSpuDTO goodsRegionSetSpuDTO){
        goodsRegionManager.setSpu(goodsRegionSetSpuDTO);
        return Result.success();
    }

    @PostMapping("/goodsRegionCategory")
    @Operation(summary = "商品区域-查询分类")
    public Result<List<GoodsRegionCategoryVO>> goodsRegionCategory(@Schema(description = "区域主键id") @RequestParam Long id){
        List<GoodsRegionCategoryVO> list = goodsRegionManager.goodsRegionCategory(id);
        return Result.success(list);
    }


    @PostMapping("/goodsRegionSpu")
    @Operation(summary = "商品区域-查询商品")
    public Result<List<GoodsRegionSpuVO>> goodsRegionSpu(@Schema(description = "分类id") @RequestParam Long categoryId){
        List<GoodsRegionSpuVO> list = goodsRegionManager.goodsRegionSpu(categoryId);
        return Result.success(list);
    }
}
